package com.rover022.flixelgame.ui.battle
{
	import com.greensock.events.LoaderEvent;
	import com.rover022.flixelgame.manager.PlayerManager;
	import com.rover022.flixelgame.ui.BaseUI;
	import com.rover022.flixelgame.ui.heroresolve.GameHeorVo;
	import flash.display.Bitmap;
 
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;

	/**
	 * 选择英雄出征界面
	 * @author flashpig
	 *
	 */
	public class ChoiceTeamPop extends BaseUI
	{
		public var mainMc:Sprite; //上面的容器
		public var subMc:Sprite; //下面的容器

		public function ChoiceTeamPop()
		{
			super();
		}

		override public function initUI(e:LoaderEvent = null):void
		{
			addEventListener(Event.REMOVED_FROM_STAGE, dispose);
			//根据冒泡者来判断.那个被点击...
			mainMc.addEventListener(MouseEvent.CLICK, clickHandle);
			subMc.addEventListener(MouseEvent.CLICK, clickHandle);
		}

		protected function clickHandle(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
		}

		protected function dispose(event:Event):void
		{
			removeEventListener(Event.REMOVED_FROM_STAGE, dispose);
			//根据冒泡者来判断.那个被点击...
			mainMc.removeEventListener(MouseEvent.CLICK, clickHandle);
			subMc.removeEventListener(MouseEvent.CLICK, clickHandle);
		}

		/**
		 * 显示我所有的英雄
		 *
		 */
		public function showMyHeros():void
		{
			var array:Array = PlayerManager.getInstance().getAllHeros();
			for (var i:int = 0; i < array.length; i++)
			{
				var _hero:GameHeorVo = array[i] as GameHeorVo;
				addHeadtoTop(_hero.view);
			}
			var teamarray:Array = PlayerManager.getInstance().getTeamByName();
			for (var j:int = 0; j < teamarray.length; j++)
			{
				_hero = PlayerManager.getInstance().getHeroByID(teamarray[j]);
				addHeadToBottom(_hero.bitmap); //把已经选择的放底部 
			}
		}

		public function addHeadToBottom(bitmap:Bitmap):void
		{
			// TODO Auto Generated method stub
		}

		public function addHeadtoTop(view:Sprite):void
		{
			// TODO Auto Generated method stub
		}

		/**
		 * 把一个英雄加入指定的队伍 
		 * @param _heroImg
		 * 
		 */		
		private function addHeroFromTeam(_heroImg:GameHeorVo):void
		{
			PlayerManager.getInstance().insertTeam(_heroImg);
			 
		}
		
		/**
		 * 把一个英雄移除指定的队伍 
		 * @param _heroImg
		 * 
		 */		
		private function removeHeroFromTeam(_heroImg:GameHeorVo):void
		{
			PlayerManager.getInstance().removeTeam(_heroImg);			
		}

		/**
		 * 显示我的常用队形
		 */
		public function showMyteam():void
		{
		}

		public function addHero():void
		{
		}
	}
}
